package com.my.socket.nio.v5;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.ByteBuffer;

public class ByteBuf {
    private static final Logger LOGGER = LoggerFactory.getLogger(ByteBuf.class);

    public static void main(String[] args) throws Exception {
        ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        LOGGER.info("position: {}, limit: {}, capacity: {}", byteBuffer.position(), byteBuffer.limit(), byteBuffer.capacity());
        byteBuffer.put("I am Alex Zhong".getBytes());
        LOGGER.info("position: {}, limit: {}, capacity: {}", byteBuffer.position(), byteBuffer.limit(), byteBuffer.capacity());
        byteBuffer.flip();
        LOGGER.info("position: {}, limit: {}, capacity: {}", byteBuffer.position(), byteBuffer.limit(), byteBuffer.capacity());
        byteBuffer.flip();
        LOGGER.info("position: {}, limit: {}, capacity: {}", byteBuffer.position(), byteBuffer.limit(), byteBuffer.capacity());

    }
}
